package com.angel.architecture.dtos;

import java.io.Serializable;
import java.util.List;

import com.angel.architecture.persistence.beans.Role;
import com.angel.architecture.persistence.beans.User;
import com.angel.architecture.persistence.beans.UserRoles;

public class UserDTO implements Serializable{

	private static final long serialVersionUID = 3093580994368353068L;

	private boolean active;
	private String id;
	private String email;
	private String password;
	private String name;
	private List<UserRoleDTO> userRoles;
	
	public UserDTO(){
		super();
	}
	
	public UserDTO(User user){
		super();
		this.setActive(user.getActive());
		this.setEmail(user.getEmail());
		this.setId(user.getIdAsString());
		this.setName(user.getName());
		this.setPassword(user.getPassword());
		UserRoles userRoles = user.getRoles();
		if(userRoles != null){
			for(Role role: userRoles.getRoles()){
				this.getUserRoles().add(new UserRoleDTO(role));
			}
		}
	}

	/**
	 * @return the active
	 */
	public boolean isActive() {
		return active;
	}

	/**
	 * @param active the active to set
	 */
	public void setActive(boolean active) {
		this.active = active;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the userRoles
	 */
	public List<UserRoleDTO> getUserRoles() {
		return userRoles;
	}

	/**
	 * @param userRoles the userRoles to set
	 */
	public void setUserRoles(List<UserRoleDTO> userRoles) {
		this.userRoles = userRoles;
	}
}
